import EventRoute from "./EventRoute"
import SystemUserService from "../service/SystemUserService";
import MainFrame from "../frames/MainFrame";

let mainWindow = null
const routes = new Array();
const systemUserService = new SystemUserService();

/**
 * 登录
 */
routes.push(
    new EventRoute('app-dologin', 'event', (api, data = {}) => {
        systemUserService.getByUsername(data.data)
        mainWindow = new MainFrame()
        api.windows['main'] = mainWindow
    })
)

/**
 * 操作员分页
 */
routes.push(
    new EventRoute('app-operator-page', 'event', async (api, data = {}) => {
        systemUserService.page(data.data)
    })
)

/**
 * 操作员添加
 */
routes.push(
    new EventRoute('app-operator-add', 'event', async (api, data = {}) => {
        systemUserService.save(data.data)
    })
)

/**
 * 操作员修改
 */
routes.push(
    new EventRoute('app-operator-update', 'event', async (api, data = {}) => {
        systemUserService.updateById(data.data)
    })
)

/**
 * 操作员删除
 */
routes.push(
    new EventRoute('app-operator-delete', 'event', async (api, data = {}) => {
        systemUserService.deleteById(data.data)
    })
)

export default routes;
